/*******************************************************************************
 * 
 * Copyright:
 * 
 * License:
 * 
 * Authors: SALMON Charles
 * 
 ******************************************************************************/

/*******************************************************************************
 * 
 ******************************************************************************/

/**
 * Create a windows to manage topics
 */
qx.Class.define("bip.ui.topics.WinManageTopics", 
{
	extend: bip.ui.win.Dialog,

	/*
	*****************************************************************************
	 EVENTS
	*****************************************************************************
	*/  
	events :
	{
		
		
	},

	/*
	*****************************************************************************
	 PROPERTIES
	*****************************************************************************
	*/ 
	properties: {
		
  	},

	/*
	*****************************************************************************
	 CONSTRUCTOR
	*****************************************************************************
	*/
	
	/**
	 * Construct the window
	 */	
 	construct: function()
	{
		this.base(arguments,"Manage topics","Manage topics",null,"bip/icon/topics.png");
		this.set({
			width: 600,
			height: 400,
			minHeight:400
		});
		
		// Populate topics
		bip.services.SynchronizedTopics.getInstance().fetchTopics();
		
	},

	/*
	*****************************************************************************
	 MEMBERS
	*****************************************************************************
	*/	
	members:
	{	
		__readyDescription: null,
		
		/**
     * Create the content of the dialog. 
     * Extending classes must implement this method.
     */
    _createWidgetContent : function()
    {
    	this.__readyDescription = this.tr("Use this form to manage topics");
  		this.setLayout(new qx.ui.layout.VBox(5));
  		var manageTopics = new bip.ui.topics.ManageTopics();
  		manageTopics.addListener("error",function(evt) {
  			this.setStateWithDescription("error",evt.getData().getMessage());
  		},this);
  		manageTopics.addListener("success",function(evt) {
  			this.setStateWithDescription("ready",this.__readyDescription);
  		},this);
  		manageTopics.addListener("running",function(evt) {
  			this.setStateWithDescription("running",evt.getData());
  		},this);
  		
  		this.add(manageTopics,{flex:1});
    },
		
		_beforeShow: function() {
			this.setStateWithDescription("ready",this.__readyDescription);
	    }
		
	    

		/*
	  	*****************************************************************************
	     UI
	  	*****************************************************************************
	 	*/
		

	},
	/*
	 * ****************************************************************************
	 * DESTRUCTOR
	 * ****************************************************************************
	 */

	destruct : function() {
		this._disposeObjects();
		
	}
	
});
